<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>上传数据文件</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-body">
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
                    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
          <div class="layui-form-item">
              <label  class="layui-form-label">
                  <span class="x-red">*</span>数据表编号
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="ssmb_bh" name="ssmb_bh" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>文件上传
            </label>
            <div class="layui-input-inline">
                <button type="button" class="layui-btn" id='test1'>
                  <i class="layui-icon">&#xe67c;</i>选择文件
                </button>
          </div>
        </div>  
    </div>
    <script>
     layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
    });
     layui.use('upload',function(){
       var upload = layui.upload;
       var uploadInst = upload.render({
         elem:'#test1'
         ,url:'/upload_sjx_wj/'
         ,accept:'file'
         ,data:{ssmb_bh:function(){return $("input[name='ssmb_bh']").val() }}
         ,done: function(res){
            //如果上传失败
            if(res.code > 0){
              return layer.msg('请输入正确的数据表编号');
            }
            return layer.msg('上传成功');
          }
          ,error: function(){
            //演示失败状态，并实现重传
            var demoText = $('#demoText');
            demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
            demoText.find('.demo-reload').on('click', function(){
              uploadInst.upload();
            });
          }
       });
     });
 </script>

  </body>

</html>